package com.wyzy.spring.project;

import com.wyzy.spring.object.MessageInfo;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RequestMapping("/messagewall")
@RestController
public class messagewall {
    private List<MessageInfo> messageInfos = new ArrayList<>();

    @RequestMapping("/publish")
    public Boolean publish(MessageInfo m){
        System.out.println(m.toString());
        if(!StringUtils.hasLength(m.getFrom())
            ||!StringUtils.hasLength(m.getTo())
            ||!StringUtils.hasLength(m.getMessage())){
            return false;
        }
        messageInfos.add(m);
        System.out.println("添加完成");
        return true;
    }
    @RequestMapping("/getList")
    public List<MessageInfo> getList(){
        System.out.println("返回列表");
        return messageInfos;
    }
}
